/*     */ package com.qmsk.business.store.saledetail.controller;
/*     */ 
/*     */ import com.qmsk.business.store.saledetail.dao.SaleDetailDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"saleDetl"})
/*     */ public class SaleDetailController
/*     */ {
/*  38 */   private static final Logger logger = Logger.getLogger(SaleDetailController.class);
/*     */ 
/*     */   @Autowired
/*     */   private SaleDetailDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  77 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  79 */       Map params = new HashMap();
/*  80 */       MapUtils.addToMap(params, "shopId", shopId);
/*  81 */       MapUtils.addPercentToMap(params, "producer", 
/*  82 */         RequestUtils.getString(request, "producer", null));
/*  83 */       MapUtils.addPercentToMap(params, "title", 
/*  84 */         RequestUtils.getString(request, "title", null));
/*  85 */       MapUtils.addPercentToMap(params, "content", 
/*  86 */         RequestUtils.getString(request, "content", null));
/*  87 */       MapUtils.addToMap(params, "dtReqStart", 
/*  88 */         RequestUtils.getDate(request, "dtReqStart", null));
/*  89 */       MapUtils.addToMap(params, "dtReqEnd", 
/*  90 */         RequestUtils.getDate(request, "dtReqEnd", null));
/*  91 */       MapUtils.addToMap(params, "dtSendStart", 
/*  92 */         RequestUtils.getDate(request, "dtSendStart", null));
/*  93 */       MapUtils.addToMap(params, "dtSendEnd", 
/*  94 */         RequestUtils.getDate(request, "dtSendEnd", null));
/*  95 */       MapUtils.addToMap(params, "status", 
/*  96 */         RequestUtils.getInt(request, "status", null));
/*  97 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  98 */         nPageSize);
/*  99 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 101 */       logger.error(e);
/* 102 */       ResponseUtils.setErrorMsgResponse(
/* 103 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/* 111 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(id);
/* 112 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 114 */       logger.error(e);
/* 115 */       ResponseUtils.setErrorMsgResponse(
/* 116 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 134 */       int nResult = 0;
/*     */ 
/* 136 */       String sData = RequestUtils.getStringOfData(request);
/* 137 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 138 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 139 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/*     */ 
/* 142 */       if (nResult > 0)
/* 143 */         DbConnection.commit();
/*     */       else {
/* 145 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 152 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 153 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 154 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 157 */       logger.error(e);
/* 158 */       DbConnection.rollback();
/* 159 */       ResponseUtils.setErrorMsgResponse(
/* 160 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 161 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}/{sendRange}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id, @PathVariable("sendRange") Integer sendRange)
/*     */   {
/*     */     try
/*     */     {
/* 181 */       int nResult = 0;
/* 182 */       String sData = RequestUtils.getStringOfData(request);
/* 183 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 184 */       if (p != null) {
/* 185 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 187 */       if (nResult > 0)
/* 188 */         DbConnection.commit();
/*     */       else {
/* 190 */         DbConnection.rollback();
/*     */       }
/* 192 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 193 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 194 */         response);
/*     */     } catch (Exception e) {
/* 196 */       logger.error(e);
/* 197 */       DbConnection.rollback();
/* 198 */       ResponseUtils.setErrorMsgResponse(
/* 199 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 200 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 216 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 218 */       String[] strParams = id.split(",");
/* 219 */       int nResult = this.dao.deleteParams(strParams);
/* 220 */       if (nResult > 0)
/* 221 */         DbConnection.commit();
/*     */       else {
/* 223 */         DbConnection.rollback();
/*     */       }
/* 225 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 226 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 227 */         response);
/*     */     } catch (Exception e) {
/* 229 */       DbConnection.rollback();
/* 230 */       logger.error(e);
/* 231 */       ResponseUtils.setErrorMsgResponse(
/* 232 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 233 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"check/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void check(HttpServletRequest request, HttpServletResponse response)
/*     */     throws SQLException
/*     */   {
/* 251 */     String id = RequestUtils.getString(request, "id");
/*     */ 
/* 254 */     int nResult = 0;
/*     */     try
/*     */     {
/* 257 */       Date dtNow = new Date();
/* 258 */       Date dtRequestDate = this.dao.getRequestDateOfId(id);
/* 259 */       if (dtRequestDate == null) {
/* 260 */         ResponseUtils.setErrorMsgResponse("没有请求发送时间,请输入", response);
/* 261 */         return;
/*     */       }
/* 263 */       if (dtRequestDate.before(dtNow)) {
/* 264 */         ResponseUtils.setErrorMsgResponse("请求发送时间超出系统时间,请更改", response);
/* 265 */         return;
/*     */       }
/* 267 */       nResult = this.dao.updateCheckedOfIds(id);
/* 268 */       if (nResult > 0)
/* 269 */         DbConnection.commit();
/*     */       else {
/* 271 */         DbConnection.rollback();
/*     */       }
/* 273 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 274 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 275 */         response);
/*     */     } catch (Exception e) {
/* 277 */       DbConnection.rollback();
/* 278 */       logger.error(e);
/* 279 */       ResponseUtils.setErrorMsgResponse(
/* 280 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 281 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.saledetail.controller.SaleDetailController
 * JD-Core Version:    0.5.3
 */